Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.default = _default;

var _api = _interopRequireDefault(require("../../../../utils/api")), _echartsConfig = require("../../echarts-config");

function _interopRequireDefault(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}

var defaultComponent = {
    init: function() {}
}, overviewDatas = [ {
    method: _echartsConfig.initPieChart,
    key: "clientfavrate"
}, {
    method: _echartsConfig.initBarChart,
    key: "clientmutual"
}, {
    method: _echartsConfig.initLineChart,
    key: "recenttrends"
} ];

function _default() {
    var u = null;
    return {
        init: function(t) {
            u = t, this.initEchatsData();
        },
        initEchatsData: function() {
            var e = this;
            overviewDatas.forEach(function(t) {
                wx.lazyFetch({
                    selector: "#chart-dom-" + t.key,
                    scope: u,
                    margins: {
                        bottom: 200
                    },
                    handler: function() {
                        return e.getAnalysis(t);
                    }
                });
            });
        },
        getAnalysis: function(t) {
            var n = this, i = t.key, a = t.method, e = u.query, o = e.guid, r = e.touid;
            _api.default.minicard.analysis.clientintelligentview({
                loading: !0,
                data: {
                    guid: o,
                    touid: r,
                    type: i
                },
                complete: wx.stopPullDownRefresh
            }).then(function(t) {
                var e = t.data;
                return n.handleOverViewCanvas(e, i, a);
            });
        },
        handleOverViewCanvas: function(t, e, n) {
            (u.selectComponent("#chart-dom-".concat(e)) || defaultComponent).init(n(t[e], "recenttrends" === e ? "niche" + e : e));
        },
        onPullDownRefresh: function() {
            this.initEchatsData();
        },
        onReachBottom: function() {}
    };
}